package com.sixth.service.impl;

import com.sixth.annotation.PageInfoAdvice;
import com.sixth.bean.MarketCollectExample;
import com.sixth.bean.common.BasePageInfo;
import com.sixth.mapper.MarketCollectMapper;
import com.sixth.service.AdminCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



/**
 * @ClassName AdminCollectServiceImpl
 * @Description TODO
 * @Author XiaoWJ
 * @Date 2022/9/7 19:34
 **/
@Service
public class AdminCollectServiceImpl implements AdminCollectService {

    @Autowired
    MarketCollectMapper marketCollectMapper;


    @PageInfoAdvice
    @Override
    public Object list(BasePageInfo basePageInfo, Integer userId, Integer valueId) {

        MarketCollectExample example = new MarketCollectExample();

        MarketCollectExample.Criteria criteria = example.createCriteria();

        // 拼接筛选条件
        if (userId != null) {
            criteria.andUserIdEqualTo(userId);
        }

        if (valueId != null) {
            criteria.andValueIdEqualTo(valueId);
        }

        // 设置排序规则
        example.setOrderByClause(basePageInfo.getSort() + " " + basePageInfo.getOrder());

        Object marketCollects = marketCollectMapper.selectByExample(example);

        return marketCollects;
    }
}
